package com.itcast.plane.modoule.flight.controller;

import com.itcast.plane.modoule.flight.domain.Flight;
import com.itcast.plane.modoule.flight.dto.FlightAppDTO;
import com.itcast.plane.modoule.flight.dto.FlightCreatDTO;
import com.itcast.plane.modoule.flight.dto.FlightEditDTO;
import com.itcast.plane.modoule.flight.service.FlightService;
import com.itcast.plane.modoule.path.domain.Path;
import com.itcast.plane.util.JsonResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/flight")
public class FlightController {

    @Resource
    private FlightService flightService;

    @PostMapping("/add")
    public JsonResult addFlight(@RequestBody FlightCreatDTO creatDTO){
        return flightService.addFlight(creatDTO);
    }

    @DeleteMapping("/delete/{id}")
    public JsonResult deleteFlight(@PathVariable int id){
        return flightService.deleteFlight(id);
    }

    @PutMapping("/edit")
    public JsonResult editFlight(@RequestBody FlightEditDTO flightEditDTO){
        return flightService.editFlight(flightEditDTO);
    }

    @GetMapping("/getpage")
    public JsonResult getFlight(@RequestParam int pages){
        return flightService.getFlight(pages);
    }

    @PostMapping("/app")
    public JsonResult getAppPage(@RequestBody FlightAppDTO appDTO){
        return flightService.getAppPage(appDTO);
    }
}
